import { request } from 'umi';
import { RentDetail } from '@/data-type'
import { BaseService } from './baseService';
class RentDetailServiceImpl implements BaseService<RentDetail> {
  async queryList(options?: { [key: string]: any; } | undefined): Promise<{ data: RentDetail[]; }> {
    let retData = {
      data: [
        {
          id: 123456,   
          amount: 1000,
          programDetailId: 123456,
          unitPrice: 100,
          days: 10,
          paid: 400,
          unpaid: 600,
          payStatus: "未结清",
          remarkId: "remarkId12345",
          startDate: new Date('2021-10-12'),
          endDate: new Date('2022-7-1'),
        },
        {
          id: 1234567,   
          amount: 1000,
          programDetailId: 123456,
          unitPrice: 100,
          days: 10,
          paid: 400,
          unpaid: 600,
          payStatus: "未结清",
          remarkId: "remarkId12345",
          startDate: new Date('2021-10-12'),
          endDate: new Date('2022-7-1'),
        }
      ],
    }
    let ret: RentDetail[] = [];
    await request("/rent-detail/query_list", {
      method: "POST",
      data: {
        "id": options?.programId,
      }
    }).then(response => {
      ret = response.data;
    })
    return Promise.resolve({data:ret});
  }
  async deleteOne(id: number): Promise<boolean> {
    console.log("need delete id is", id);
    await request("/rent-detail/delete_one", {
      method: "DELETE",
      data: {
        id
      }
    }).then(response => {
      // ret = response.data;
    })
    return Promise.resolve(true);
  }
  async updateOne(entity: RentDetail): Promise<boolean> {
    console.log("need update id is", entity);
    await request("/rent-detail/update_one", {
      method: "PUT",
      data: {
        ...entity
      }
    }).then(response => {
      // ret = response.data;
    })
    return Promise.resolve(true);
  }
  async save(entity: RentDetail): Promise<boolean> {
    console.log("保存成功");
    await request("/rent-detail/save_one", {
      method: "POST",
      data: {
        ...entity
      }
    }).then(response => {
      // ret = response.data;
    })
    return Promise.resolve(true);
  }
}
export const RentDetailService =new RentDetailServiceImpl();